$(document).ready(init_edit_media);

function init_edit_media() {
  init_media_uploader(); 
  
  $('#create_page,#parent_page,#add_to_page,#to_page').change(reload_media);
}

function reload_media(){
 str = $('#create_page,#parent_page,#add_to_page,#to_page').serialize();
 document.location = '?' + str; 
}

function save_media(){
  document.getElementById('form_media').submit();
}


function delete_media(){
  if(confirm("Are you sure want to delete this media?")){
    $('#delete').val('1');
     
    save_media();   
  }
} 